//var baseUrl="http://dev.hccloud.com/"//beseurl
var baseUrl="https://29858960.qcloud.la/"//beseurl

var UtilProperty=new Object;//所有作品的信息
//作品id
var user_id,token;
var pageEnd=true;//作品列表加载到最后一页
var pageNoSize=1;//作品列表页
var open_id='oNq6Ijk-5oGy51ag8D6HSRhqbgfI';
var fans_id;//有赞用户id
function baseAjax(urlstr,type,obj,fn)//基本的接口访问
{
	
	$.ajax({ 
			  		
		url:baseUrl+urlstr,	
		type:type,
		dataType:"json",		
		data:obj,		
        success:function(data){
        	if(data.code!=200){				
				 $.alert(data.description, "提示");
				 if(!$("#loadtoast").is(":hidden")){
				 	$("#loadtoast").hide();
				 }
			}else{
				fn(data);
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){	
				if(XMLHttpRequest.status==0){					
					$.alert('加载失败，请重新加载', "提示");
					
				}else{					
					$.alert(XMLHttpRequest.status, "提示");
				}
				 if(!$("#loadtoast").is(":hidden")){
					 	$("#loadtoast").hide();
						 }			
		}
    });
  
	
}

function GetRequest() {  

		   var url = location.search; //获取url中"?"符后的字串
   		   var theRequest = new Object();
	   if (url.indexOf("?")!= -1) {
	      var str = url.substr(1);
	      strs = str.split("&");
		      for(var i = 0; i < strs.length; i ++) {
		         theRequest[strs[i].split("=")[0]]=strs[i].split("=")[1];
		      }
		 }   
   		return theRequest;
	} 
	

//校验是否登陆
function checkoutlogin(){
	/*var strcookie = document.cookie;//获取cookie字符串
	//var strcookie="user_id=1; token=HsXHnzdM2YxgruH4Jqqzds%252BDJmzzbVHV7BsTN9ALOdswPEtEZnScILqHfaOObK1xz48k2olAJt7QwN05ei%252Fliw%253D%253D";
	
	var arrcookie = strcookie.split("; ");//分割
	//遍历匹配
	for ( var i = 0; i < arrcookie.length; i++) {
		var arr = arrcookie[i].split("=");
		if (arr[0] == 'user_id'){
			user_id=arr[1];
		}
		if (arr[0] == 'token'){
			token=arr[1];
		}
		if (open_id[0] == 'open_id'){
			open_id=arr[1];
		}
	}*/
	//$.cookie('user_id', user_id, {path: '/' }); 
	user_id=$.cookie('user_id');
	token=$.cookie('token');
	if(user_id&&token){		
		$.ajax({ 				  		
			url:baseUrl+'wechat/login/verifytoken',	
			type:'GET',	
			dataType:"json",		
			data:{},	
	        success:function(data){
	        	if(data.code!=200){
	        		if(data.code!=404){
	        			
	        			 clearCookie('token', '.29858960.qcloud.la');
    					 clearCookie('user_id', '.29858960.qcloud.la');
    					 $("#loadtoast .weui-mask_transparent").hide();
	        			$("#diatips").attr("checklogin","1");				 		
				 		$.alert(data.description, "错误");
	        		}	        		
				 	
				}else{
				//获取用户信息
				user_id=$.cookie('user_id'); 
				getuser_info();
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){	
					
						if(XMLHttpRequest.status==0){						
							$.alert('加载失败，请重新加载！', "提示");
							 if(!$("#loadtoast").is(":hidden")){
						 	$("#loadtoast").hide();
							 }
						}else{							
							$.alert(XMLHttpRequest.status, "提示");
						}
					
					
			}
    	});
	}else{
		window.location.href=baseUrl+'wechat/login';			
	}
	
}